<!DOCTYPE html>
<html lang="en">
<title>围裙健身管理后台</title>
<#import "/layout/layout.html" as body/>
<@body.page>

<!--<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h1>修改密码</h1>
        <ol class="breadcrumb">
            <li><a href="index.html">檬运动管理后台</a></li>
        </ol>
    </div>
</div>-->
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title overflow">
                    <h5 class="pull-left">修改密码</h5>
                </div>
                <div class="ibox-content">
                    <form method="get" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">原密码</label>
                            <div class="col-sm-10">
                                <input type="password" id="oldPwd" name="oldPwd" class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">新密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="newPwd" id="newPwd" class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">确认新密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="newPwd2" id="newPwd2" class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                    </form>
                </div>
                <div class="ibox-content overflow">
                    <div class="col-sm-12">
                        <button type="button" onclick="javascript:window.location.href=history.go(-1)" class="btn btn-default pull-left">取消修改</button>
                        <button type="button" id="sub" class="btn btn-primary pull-right">确认修改</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function () {

        $("#sub").click(function () {

            var oldPwd = $("#oldPwd").val();
            var newPwd = $("#newPwd").val();
            var newPwd2 = $("#newPwd2").val();

            if (oldPwd == '') {
                alert("原密码不能为空!");
                $("#oldPwd").focus();
                return;
            }
            if (newPwd == '') {
                alert("新密码不能为空!");
                $("#newPwd").focus();
                return;
            }
            if (newPwd2 == '') {
                alert("确认新密码不能为空!");
                $("#newPwd2").focus();
                return;
            }

            if (newPwd != newPwd2) {
                alert("请确认新密码是否相等!");
                $("#newPwd").focus();
                return;
            }

            var url = 'change_password';
            var d = $("form").serialize();
            $.ajax({
                url: url,
                type: 'POST',
                data: d,
                async: false,
                success: function (returndata) {
                    if (returndata > 0) {
                        alert("修改成功!");
                        window.history.go(-1);
                    } else {
                        alert("修改失败,请检查原密码是否正确!");
                    }
                },
                error: function (returndata) {
                    alert(returndata);
                }
            });


        });
    });
</script>
</@body.page>
</html>
    